#include <fcntl.h>
#include <stdio.h>
#include "open.h"

int system_open(int argc, char* argv[]){
	
	int fd;
	int i, n;
	char buf[4096];
	if(argc < 2) exit(1);
	fd = open(argv[1], O_RDONLY);
	if(fd < 0) exit(2);
	while(n = read(fd, buf, 4096)){
			for(i = 0; i < n; i++){
				write(1, &buf[i], 1);
			}
	}
}


int lib_open(int argc, char* argv[]){
	FILE *fp;
	int c; //for EOF of stdio

	if(argc < 2) exit(1);
	fp = fopen(argv[1], "r");
	if(fp == 0) exit(2);

	while((c = fgetc(fp) != EOF)){
			putchar(c);
	}
}

